import numpy as np
def generate_rectangle_data():
    total_points = 80000
    # 定义区域边界
    x_min, x_max = 0, 1
    y_min, y_max = 0, 0.2
    
    # 定义不同区域的采样点数
    n_velocity_inlet_0 = 2500
    n_pressure_outlet_0 = 2500
    n_wall = 5000
    n_interior = 70000
    
    # 生成velocity_inlet_0区域的采样点 (x=0)
    velocity_inlet_0 = np.zeros((n_velocity_inlet_0, 2))
    velocity_inlet_0[:, 1] = np.random.uniform(y_min, y_max, n_velocity_inlet_0)
    
    # 生成pressure_outlet_0区域的采样点 (x=1)
    pressure_outlet_0 = np.zeros((n_pressure_outlet_0, 2))
    pressure_outlet_0[:, 0] = x_max
    pressure_outlet_0[:, 1] = np.random.uniform(y_min, y_max, n_pressure_outlet_0)
    
    # 生成wall区域的采样点 (y=0 和 y=0.2)
    wall = np.zeros((n_wall, 2))
    wall[:n_wall//2, 0] = np.random.uniform(x_min, x_max, n_wall//2)
    wall[:n_wall//2, 1] = y_min
    wall[n_wall//2:, 0] = np.random.uniform(x_min, x_max, n_wall//2)
    wall[n_wall//2:, 1] = y_max
    
    # 生成interior区域的采样点
    interior = np.zeros((n_interior, 2))
    interior[:, 0] = np.random.uniform(x_min, x_max, n_interior)
    interior[:, 1] = np.random.uniform(y_min, y_max, n_interior)
    
    # 将所有点存储为字典
    data = {
        'velocity_inlet_0': velocity_inlet_0,
        'pressure_outlet_0': pressure_outlet_0,
        'wall_0': wall,
        'interior': interior
    }
    
    # 保存为npz文件
    np.savez('data/rectangle_mesh.npz', **data)

# 调用函数生成数据
generate_rectangle_data()
